const moment = require('moment');
// var date = new Date();
// const month = moment(date).format('YYYY-MM');
// console.log('month:' + month);
// // var month = date.getMonth();     //当前月：0-11
// const string = month.slice(5);
// console.log('string:' + string);

// for (let m = string; m > 0; m--) {
//   console.log('m:' + m);
// }


var date = new Date();
var year = date.getFullYear();
var month = parseInt(date.getMonth()+1);
let result = [];
for (let i = month; i > 0; i--) {
  if (i < 10) {
    i = '0' + i;
  }
  const table_name = 'compression_flow_stats-' + year + '-' + i;
  // console.log('table_name:' + table_name);
  result = result.concat([1]);
}
console.log('result:' + result);

var arr = [0,'2022-01-01 01:05:00', '2022-01-01 01:30:00', '2022-01-01 01:40:00', '2022-01-26 10:00:00'];
var max = Math.min(...arr);
console.log('max=' + max)  //6


// var time = new Date('2022-01-01 01:05:00');
// console.log('time:' + time);

var dates=[];
// dates.push(new Date('2022-01-01 01:05:00'))
// dates.push(new Date('2022-01-01 01:30:00'))
// dates.push(new Date('2022-01-01 01:40:00'))
// dates.push(new Date('2022-01-26 10:00:00'))
for(let i = 0; i < arr.length; i++) {
  dates.push(new Date(arr[i]));
}
console.log('dates:' + dates);
var maxDate=new Date(Math.max.apply(null,dates));
var minDate=new Date(Math.min.apply(null,dates));
const start_time = moment(maxDate).unix();
console.log('maxDate:' + maxDate);
console.log('minDate:' + minDate);
console.log('start_time:' + start_time);




